package com.basic.business.actionPoint.controller;


import com.basic.business.actionPoint.domain.TActionPoint;
import com.basic.business.actionPoint.service.ITActionPointService;
import com.basic.common.annotation.FileExport;
import com.basic.common.annotation.Log;
import com.basic.common.core.controller.BaseController;
import com.basic.common.core.domain.AjaxResult;
import com.basic.common.core.page.TableDataInfo;
import com.basic.common.enums.BusinessType;
import com.basic.common.utils.easyExcel.EasyExcelUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

/**
 * 商品行动点管理Controller
 *
 * @author zhaoxy_jn@163.com
 */
@RestController
@RequestMapping("/business/actionPoint")
public class TActionPointController extends BaseController
{
    @Resource
    private ITActionPointService tActionPointService;

    /**
     * 查询商品行动点管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:actionPoint:list')")
    @GetMapping("/list")
    public TableDataInfo list(TActionPoint tActionPoint)
    {
        startPage();
        List<TActionPoint> list = tActionPointService.getList(tActionPoint);
        return getDataTable(list);
    }

    /**
     * 导出商品行动点管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:actionPoint:export')")
    @Log(title = "商品行动点管理", businessType = BusinessType.EXPORT)
    @FileExport(fileName = "商品行动点管理.xlsx")
    @PostMapping("/export")
    public String export(TActionPoint tActionPoint) throws IOException
    {
        List<TActionPoint> list = tActionPointService.getList(tActionPoint);
        return EasyExcelUtils.excelExport(TActionPoint.class,"商品行动点管理数据", list);
    }

    /**
     * 获取商品行动点管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:actionPoint:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tActionPointService.get(id));
    }

    /**
     * 新增商品行动点管理
     */
    @PreAuthorize("@ss.hasPermi('business:actionPoint:add')")
    @Log(title = "商品行动点管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TActionPoint tActionPoint)
    {
        return toAjax(tActionPointService.insert(tActionPoint));
    }

    /**
     * 修改商品行动点管理
     */
    @PreAuthorize("@ss.hasPermi('business:actionPoint:edit')")
    @Log(title = "商品行动点管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TActionPoint tActionPoint)
    {
        return toAjax(tActionPointService.update(tActionPoint));
    }

    /**
     * 删除商品行动点管理
     */
    @PreAuthorize("@ss.hasPermi('business:actionPoint:remove')")
    @Log(title = "商品行动点管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tActionPointService.deleteByIds(ids));
    }
}
